package com.ybt.service.impl.base;

import com.ruleengine.context.IContextProperty;
import com.ruleengine.context.IWorkflowConext;
import com.ruleengine.context.impl.ContextPropertyFactory;
import com.ruleengine.endpoint.data.IEndpointData;
import com.ybt.context.IYBTContextConstants;
import com.ybt.service.exception.ServiceException;
import com.ybt.service.impl.BlockingBaseService;
import com.ybt.transaction.TransactionMapping;

public class ServiceIdentify extends BlockingBaseService {

    @Override
    public void service(IWorkflowConext context, IEndpointData data)
            throws ServiceException {
        // 外部交易码
        IContextProperty<String> outCodep = context
                .getContextProperty(IYBTContextConstants.OUT_TRANCODE);
        String outCode = outCodep.getValue();
        
        // 渠道
        IContextProperty<String> channelp = context
        .getContextProperty(IYBTContextConstants.YBT_CHANNEL);
        String channel = channelp.getValue();
        
        String service = TransactionMapping.getInstance().getServiceWorkflow(channel, outCode);
        
        // 设置识别的服务
        IContextProperty<String> sPro = ContextPropertyFactory
                .getInstance().createPublicVariable(
                        IYBTContextConstants.YBT_SERVICE);
        sPro.setValue(service);
        context.setContextProperty(sPro);
    }

}
